class Solution(object):
    def minNonZeroProduct(self, p):
        base = 10 ** 9 + 7
        t = pow(2, p, base) - 1
        c = pow(2, p, base) - 2
        if p == 1:
            return t
        else:
            for i in range(p - 1):
                t = t * c % base
                c = pow(c, 2, base)
            return t

